﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProductCollector;

namespace ThemeCupid.FrontEnd
{
    public partial class SearchResult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string siteName = Request.QueryString["Site"];
                string valueSearch = Request.QueryString["Value"];
                ISiteSearcher searcher = SiteSearcherFactory.CreateSearcher(siteName);
                if (string.IsNullOrEmpty(siteName))
                    return;
                var searchCriteria = new SearchCriteria
                    {
                        Category = "",
                        SearchValue = valueSearch,
                        CurrentPageIndex = 1,
                        AllCategory = true
                    };
                var productList = searcher.Search(searchCriteria);
                DataList1.DataSource = productList;
                DataList1.DataBind();
            }
        }
    }
}